package com.GDOU.service.serviceImp;

import com.GDOU.bean.TLeave;
import com.GDOU.bean.TLeaveExample;
import com.GDOU.mapper.TLeaveMapper;
import com.GDOU.service.LeaveInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LeaveInfoServiceImpl implements LeaveInfoService {

    @Resource
    TLeaveMapper tLeaveMapper;


    @Override
    public List<TLeave> ajaxSplit(Integer stuId, Integer typeId, Integer statuId) {
        List<TLeave> list = tLeaveMapper.ajaxSplit(stuId, typeId, statuId);
        return list;
    }


    @Override
    public List<TLeave> spilt(Integer stuId) {
        TLeaveExample tLeaveExample = new TLeaveExample();
        tLeaveExample.createCriteria().andStuIdEqualTo(stuId);

        List<TLeave> list = tLeaveMapper.selectByExample(tLeaveExample);

        return list;
    }

    @Override
    public int save(TLeave tLeave) {
        int count = tLeaveMapper.insert(tLeave);
        return count;
    }

    @Override
    public TLeave getBeginAndEndTime(int id) {

        TLeave tLeave = tLeaveMapper.selectByPrimaryKey(id);
        return tLeave;
    }

    @Override
    public int update(TLeave tLeave) {
        int count = tLeaveMapper.updateByPrimaryKey(tLeave);
        return count;
    }

    @Override
    public int delete(int id) {
        int count = tLeaveMapper.deleteByPrimaryKey(id);
        return count;
    }

}
